{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fb060a3f",
   "metadata": {},
   "outputs": [],
   "source": [
    "stu_id = [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "03dc59aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu_id: [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001] \n",
      " stu_id_matedata: [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n"
     ]
    }
   ],
   "source": [
    "# 1. copy()很重要\n",
    "# 赋值不是真正的复制 赋值不等价copy\n",
    "# 且无论两边有一边变化，则两边都会有所改变\n",
    "stu_id_matedata = stu_id\n",
    "print(\"stu_id:\", stu_id,'\\n', 'stu_id_matedata:', stu_id_matedata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "f2850433",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原先的值: [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n",
      "stu_id: [1001, 1003, 1004, 1005, 1001, 1006, 1007, 1001] \n",
      " stu_id_matedata: [1001, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n",
      "stu_id: [1001, 1004, 1005, 1001, 1006, 1007, 1001] \n",
      " stu_id_matedata: [1001, 1004, 1005, 1001, 1006, 1007, 1001]\n"
     ]
    }
   ],
   "source": [
    "# 实验 1 赋值\n",
    "stu_id = [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n",
    "print(\"原先的值:\",stu_id)\n",
    "stu_id_matedata = stu_id\n",
    "\n",
    "stu_id.pop(1)\n",
    "print(\"stu_id:\", stu_id, '\\n', 'stu_id_matedata:', stu_id_matedata)\n",
    "\n",
    "stu_id_matedata.pop(1)\n",
    "print(\"stu_id:\", stu_id, '\\n', 'stu_id_matedata:', stu_id_matedata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "b58aada4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原先的值: [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n",
      "stu_id: [1001, 1003, 1004, 1005, 1001, 1006, 1007, 1001] \n",
      " stu_id_matedata: [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n",
      "stu_id: [1001, 1003, 1004, 1005, 1001, 1006, 1007, 1001] \n",
      " stu_id_matedata: [1001, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n"
     ]
    }
   ],
   "source": [
    "# 实验2 copy()\n",
    "stu_id = [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n",
    "print(\"原先的值:\",stu_id)\n",
    "stu_id_matedata = stu_id.copy()\n",
    "\n",
    "stu_id.pop(1)\n",
    "print(\"stu_id:\", stu_id, '\\n', 'stu_id_matedata:', stu_id_matedata)\n",
    "\n",
    "stu_id_matedata.pop(1)\n",
    "print(\"stu_id:\", stu_id, '\\n', 'stu_id_matedata:', stu_id_matedata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "1a600906",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu_id: [1001, 1003, 1004, 1005, 1001, 1006, 1007, 1001] \n",
      " stu_id_matedata: [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n"
     ]
    }
   ],
   "source": [
    "# 实验3 切片实现复制\n",
    "stu_id = [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n",
    "stu_id_matedata = stu_id[:]\n",
    "stu_id.pop(1)\n",
    "print(\"stu_id:\", stu_id, '\\n', 'stu_id_matedata:', stu_id_matedata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "ffb5974e",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stu_id: [1001, 1003, 1004, 1005, 1001, 1006, 1007, 1001] \n",
      " stu_id_matedata: [1001, 1002, 1003]\n"
     ]
    }
   ],
   "source": [
    "stu_id = [1001, 1002, 1003, 1004, 1005, 1001, 1006, 1007, 1001]\n",
    "stu_id_matedata = stu_id[0:3]\n",
    "stu_id.pop(1)\n",
    "print(\"stu_id:\", stu_id, '\\n', 'stu_id_matedata:', stu_id_matedata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d675e84",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
